//
//  TabBarViewController.m
//  SLYTravel
//
//  Created by 锁飞 on 16/5/17.
//  Copyright © 2016年 锁腾飞. All rights reserved.
//

#import "TabBarViewController.h"
#import "LCLoginViewController.h"
#import "PlansViewController.h"
#import "TravelsViewController.h"
<<<<<<< HEAD
#import "SFHomePageViewController.h"
=======
#import "HomePageViewController.h"
>>>>>>> 12a33b3d2b89ccec9b9a0edf1985ffae3a9cc596
#import "NavigationController.h"

@interface TabBarViewController ()

@end

@implementation TabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSMutableDictionary *attrsDic = [NSMutableDictionary dictionary];
    attrsDic[NSForegroundColorAttributeName] = [UIColor lightGrayColor];
    attrsDic[NSFontAttributeName] = [UIFont systemFontOfSize:12];
    
    NSMutableDictionary *selectedAttrisDic = [NSMutableDictionary dictionary];
    selectedAttrisDic[NSFontAttributeName] = [UIFont systemFontOfSize:12];
    selectedAttrisDic[NSForegroundColorAttributeName] = [UIColor colorWithRed:0.12 green:0.73 blue:0.82 alpha:1];
    
    UITabBarItem *item = [UITabBarItem appearance];
    [item setTitleTextAttributes:attrsDic forState:UIControlStateNormal];
    [item setTitleTextAttributes:selectedAttrisDic forState:UIControlStateSelected];
    self.tabBar.barTintColor = [UIColor whiteColor];
    
<<<<<<< HEAD
    [self setupChildVC:[[SFHomePageViewController alloc] init] andTitle:@"首页" andImageName:@"tab_home~iphone" andSelectedImageName:@"tab_home_selected~iphone"];
=======
    [self setupChildVC:[[HomePageViewController alloc] init] andTitle:@"首页" andImageName:@"tab_home~iphone" andSelectedImageName:@"tab_home_selected~iphone"];
>>>>>>> 12a33b3d2b89ccec9b9a0edf1985ffae3a9cc596
    
    [self setupChildVC:[[TravelsViewController alloc] init] andTitle:@"游记" andImageName:@"tab_activities~iphone" andSelectedImageName:@"tab_activities_selected~iphone"];
    
    [self setupChildVC:[[PlansViewController alloc] init] andTitle:@"路线" andImageName:@"tab_plans~iphone" andSelectedImageName:@"tab_plans_selected~iphone"];
    
    [self setupChildVC:[[LCLoginViewController alloc] init] andTitle:@"我" andImageName:@"tab_me~iphone" andSelectedImageName:@"tab_me_selected~iphone"];
    
    
    
}

/**
 *  初始化子控制器
 *
 *  @param viewController 要添加的控制器
 *  @param title          文字
 *  @param image          图片
 *  @param selectedimage  选中时的图片
 */
- (void)setupChildVC:(UIViewController *)VC
            andTitle:(NSString *)title
        andImageName:(NSString *)imageName
andSelectedImageName:(NSString *)selectedImage {
    VC.tabBarItem.title = title;
    VC.tabBarItem.image = [UIImage imageNamed:imageName];
    VC.tabBarItem.selectedImage = [UIImage imageNamed:selectedImage];
    
    NavigationController *navigation = [[NavigationController alloc] initWithRootViewController:VC];
    [self addChildViewController:navigation];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
